import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
import { v4 as uuidv4 } from 'uuid';

@Entity('manager')
export class Manager {
  @PrimaryGeneratedColumn({ type: 'int', comment: 'id' })
  id: number;

  @Column({
    type: 'boolean',
    comment: '是否被删除',
    default: false,
  })
  isDelete: boolean;

  @Column({
    type: 'varchar',
    comment: '用户主 id',
    nullable: false,
    default: () => `'${uuidv4().replace(/-/g, '')}'`,
  })
  primary_id: string;

  @Column({ type: 'varchar', comment: '姓名', nullable: false })
  name: string;

  @Column({
    type: 'varchar',
    comment: '头像',
    nullable: true,
    default: '/vehicle/default_avatar.png',
  })
  cover: string;

  @Column({
    type: 'varchar',
    comment: '用户的密码',
    select: false,
    nullable: false,
  })
  password: string;

  @Column({
    type: 'varchar',
    comment: '类型',
    nullable: true,
    default: 'manager',
  })
  type: string;

  @Column({ type: 'varchar', comment: '昵称', nullable: true })
  nickname: string;

  @Column({ type: 'varchar', comment: '性别', nullable: true })
  sex: string;

  @Column({ type: 'varchar', comment: '省', nullable: false })
  province: string;

  @Column({ type: 'varchar', comment: '城市', nullable: false })
  city: string;

  @Column({ type: 'int', comment: '年龄', nullable: true })
  age: number;

  @Column({ type: 'varchar', comment: '管理员的手机号码', nullable: false })
  phone: string;

  @Column({
    type: 'varchar',
    comment: '0 代表超级管理员,1代表普通管理员',
    nullable: false,
    default: '1',
  })
  role: string;

  @Column({ type: 'varchar', comment: '管理员的描述信息', nullable: true })
  description: string;

  @Column({
    type: 'varchar',
    comment: '管理员的状态, 1 代表启用，0 代表禁用',
    default: '1',
  })
  status: string;

  @Column({
    name: 'create_date',
    type: 'timestamp',
    comment: '创建时间',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createDate: Date;

  @Column({
    name: 'update_date',
    type: 'timestamp',
    comment: '修改时间',
    nullable: true,
  })
  updatedDate: Date;
}
